package cn.sang.web;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import cn.sang.model.vo.IndexCompositionListVO;
import cn.sang.service.CompositionService;
import cn.sang.util.AjaxResult;

@RequestMapping("/normal")
@Controller
public class CompositionController {
	
	@Resource
	private CompositionService compositionService;
	
	/**
	 * 首页展示最新批改作文列表
	 * @return
	 */
	@RequestMapping("/indexCompositionList.do")
	@ResponseBody
	public List<IndexCompositionListVO> indexCompositionList(){
		List<IndexCompositionListVO> indexCompositionList = compositionService.indexCompositionList();
		return indexCompositionList;
	}
	
	/**
	 * 上传作文
	 * @param request
	 */
	@RequestMapping("/uploadComposition")
	@ResponseBody
	public AjaxResult uploadComposition(HttpServletRequest request,
			@RequestParam("compositionFile") MultipartFile compositionFile){
		
		AjaxResult uploadComposition = compositionService.uploadComposition(request, compositionFile);
		return uploadComposition;
	}
	
}
